﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BusinessLogic.Interfaces;
using Domain;
using Domain.Entities;

namespace BusinessLogic.Implementations
{
    public class EFRolesRepository: IRolesRepository
    {
        private DomainContext context;
        public EFRolesRepository(DomainContext context)
        {
            this.context = context;
        }

        public IEnumerable<Role> GetRoles()
        {
            return context.Roles;
        }

        public Role GetRoleById(int id)
        {
            return context.Roles.FirstOrDefault(x => x.ID == id);
        }

        public Role GetRoleByName(string name)
        {
            return context.Roles.FirstOrDefault(x => x.Name == name);
        }
    }
}
